<template>
	<view class="container">
		<view class="content top">
			<view class="tit">手机号</view>
			<input type="text" placeholder="请输入手机号" v-model="phone">
		</view>
		<view class="title">反馈类型</view>
		<view class="content">
			<view class="tag" v-for="(item,index) in list" :key="index" :class="current==index?'active':''"
				@click="tagClick(index)">{{item}}
			</view>
		</view>
		<view class="title">反馈内容</view>
		<view class="content">
			<textarea name="" id="" v-model="content" maxlength="-1" placeholder="请输入反馈内容"></textarea>
		</view>
		<view class="submit" @click="submit">
			提交
		</view>
	</view>
</template>

<script>
	import index from '../uview-ui'
	export default {
		data() {
			return {
				current: 0,
				list: ['售后/退款', '我要催货', '新用户咨询', '发货到外地咨询', '其他'],
				phone: '',
				content: '',
				type: '',
				phoneZz: /^1(3|4|5|6|7|8|9)\d{9}$/,
			}
		},
		methods: {
			tagClick(index) {
				this.current = index
			},
			submit() {
				if (!(this.phoneZz.test(this.phone))) {
					this.$u.toast('请输入正确的手机号')
					return false
				} else if (this.content == '') {
					this.$u.toast('请输入反馈内容')
					return false
				}
				this.$allApi.getFeedback({
					phone: this.phone,
					content: this.content,
					type: this.list[this.current],
				}).then(res => {
					this.$u.toast('添加反馈成功')
					setTimeout(() => {
						this.$backTo()
					}, 1500)
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.submit {
		width: 710rpx;
		height: 80rpx;
		border-radius: 10rpx;
		background: #40AE36;
		left: 20rpx;
		position: fixed;
		bottom: calc(20rpx + constant(safe-area-inset-bottom));
		bottom: calc(20rpx + env(safe-area-inset-bottom));
		display: flex;
		align-items: center;
		justify-content: center;
		color: #fff;

	}

	textarea {
		padding: 20rpx;

	}

	.tag {
		border-radius: 24rpx;
		display: inline;
		height: 48rpx;
		line-height: 48rpx;
		border: 2rpx solid #DCDCDC;
		padding: 0 20rpx;
		font-size: 24rpx;
		color: #666;
		margin-right: 20rpx;
		margin-bottom: 20rpx;
	}

	.active {
		background: #40AE36;
		border: none;
		color: #fff;
	}

	.title {
		margin-bottom: 20rpx;
	}

	.top {
		display: flex;
		align-items: center;
		justify-content: space-between;

		input {
			flex: 1;
			margin-left: 20rpx;
			font-size: 24rpx;
		}
	}

	.content {
		background: #fff;
		margin-bottom: 20rpx;
		padding: 20rpx;
		border-radius: 10rpx;
	}

	.container {
		min-height: 100vh;
		background: #f8f8f8;
		padding: 20rpx;

	}
</style>